%%
%% This is file `cag.sty',
%% generated with the docstrip utility.
%%
%% Copyright 2017 Elsevier Ltd
%% 
%% This file is part of the 'Elsarticle Bundle'.
%% -------------------------------------------
%% 
%% It may be distributed under the conditions of the LaTeX Project Public
%% License, either version 1.2 of this license or (at your option) any
%% later version.  The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%% 
%%
%% $Id: cag.sty 88 2017-06-09 07:40:26Z rishi $
%%
 \def\RCSfile{cag}%
 \def\RCSversion{1.0}%
 \def\RCSdate{2017/03/03}%
 \def\@shortjnl{\relax}
 \def\@journal{Computers \& Graphics}
 \def\@company{Elsevier Ltd.}
 \def\@issn{0097-8493}
 \def\@shortjid{cag}
\NeedsTeXFormat{LaTeX2e}[1995/12/01]

\@ifclassloaded{elsarticle}
{\typeout{elsarticle.cls is loaded...}}
{\errmessage{This package will work only with 
  elsarticle.cls. So please load elsarticle.cls 
  and try.}}
  
\@ifpackageloaded{hyperref}{}
   {\def\href#1#2{#2}}  
  
\AtBeginDocument{\@twosidetrue\@mparswitchtrue}

\def\@verso{}
\gdef\verso#1{\gdef\@verso{#1}}

\gdef\baselinestretch{1}%
\gdef\belowabstractskip{10pt}%

 \RequirePackage{geometry}
 \geometry{twoside,
  paperwidth=210mm,
  paperheight=280mm,
  textheight=635.35pt,
  textwidth=467.75pt,
  inner=32pt,
  outer=43pt,
  top=65pt,
  bottom=40pt,
  headheight=12pt,
  headsep=12pt,
  footskip=16pt,
  footnotesep=28pt plus 2pt minus 6pt,
  columnsep=18pt
 }
 \global\let\bibfont=\footnotesize
 \global\bibsep=0pt
 \input{fleqn.clo}
%\ifpreprint
%\else
%   \global\@twocolumntrue
%\fi

\long\def\elsputbox(#1)(#2)[#3]#4{%
       \unitlength=1mm%
       \fboxsep=-\fboxrule
       \fboxrule0pt%
       \fboxsep0pt%
       \ifvmode\leavevmode\fi\smash{\put(#1)%
       {\makebox(#2)[#3]{\fbox{#4}}}}}
       
\long\def\elsptputbox(#1)(#2)[#3]#4{%
       \unitlength=1pt%
       \fboxsep=-\fboxrule
       \fboxrule0pt%
       \fboxsep0pt%
       \ifvmode\leavevmode\fi\smash{\put(#1)%
       {\makebox(#2)[#3]{\fbox{#4}}}}}

\usepackage{multirow}
\usepackage{color}

\definecolor{gray10}{gray}{.9}

\AtBeginDocument{
\def\elsarticletitlealign{flushleft}
}

%%
\def\snm#1{\textcolor{red}{#1}}

\def\tnotemark[#1]{\@for\mytmark:=#1\do{%
       \@ifundefined{X@\mytmark}%
          {\expandafter\def\csname X@\mytmark\endcsname{0}}%
          {}%
       \expandafter\ifcase\csname X@\mytmark\endcsname\or$^{\star}$\or
       $^{,\star\star}$\fi
    }%
}

\def\elstitleheaderwidth{\textwidth}%165mm
\def\titleboxawidth{159.5mm}
\def\elsjnllogowidth{20mm}
\def\titleblocksep{4mm}%
\def\titlegrayboxwidth{132.5mm}
\def\titlegrayboxheight{20.75mm}
\def\elsjnllogoheight{25.24mm}
\def\elstitleboxcolor{gray10}
\def\ScienceDirect{\href{http://www.sciencedirect.com}{ScienceDirect}}
\if@twocolumn%
  \def\abovestmtitleheaderskip{-16pt}%
\else%
  \def\abovestmtitleheaderskip{-28pt}%
\fi%
\def\crossmarkskip{25mm}
\def\jnllogo{cag-logo}
\def\elslogo{elsevier-logo}
\def\jnlurl#1{\gdef\@jnlurl{#1}}
\gdef\@jnlurl{www.elsevier.com/locate/cag}

\def\elstitleheadboxa#1#2#3{%
    \minipage[b][][t]{#1}%
     \hrule width #1 height 0.3pt%
     \vspace*{6pt}%
       {\raisebox{-3pt}{\includegraphics%
          {\elslogo}\hspace*{\titleblocksep}}}%
     \colorbox{\elstitleboxcolor}{%     
       \parbox[b][#2]{#3}{\elstitlejnldetails}}%
   \endminipage%
}

\def\elstitlejnldetails{%
    \minipage[b][23mm][b]{\titlegrayboxwidth}%
       \centering%
       \parbox[b]{\titlegrayboxwidth}{%       
       \centering\sffamily%
       \fontsize{8.5pt}{9.6pt}\fontseries{m}\selectfont%       
       Contents lists available at \ScienceDirect}\\[15pt]%
       {\fontsize{15pt}{18pt}\selectfont%
        \@journal%
       }\\[15pt]%
       \parbox[b]{\titlegrayboxwidth}%
       {\centering\sffamily\fontsize{8.5pt}{9.6pt}\fontseries{m}\selectfont%       
       journal homepage:~%
       \href{http://\@jnlurl}{\@jnlurl}%
       \vspace*{0pt}%
       }%
      \endminipage}

\def\elsjnllogoboxb#1#2{%
  \minipage[b][#2][b]{#1}%
      {\fboxrule=0.2pt\fboxsep=0pt\fbox{%
        \includegraphics[width=20.22mm,height=25.47mm]{\jnllogo}}}%
  \endminipage}
  
\def\titleheaderfont{\fontsize{8pt}{8pt}\selectfont}
  
\def\stmtitleheader{%
  {\parskip=0pt%
   \parindent=0pt%
   \vspace*{\abovestmtitleheaderskip}%
   \minipage[t][][t]{\elstitleheaderwidth}%
   \par\vspace*{9pt}%
   \elstitleheadboxa{\titleboxawidth}%
     {\titlegrayboxheight}{\titlegrayboxwidth}%
     \hspace*{\dimexpr(\titleblocksep-0.3pt)}%
   \elsjnllogoboxb{\elsjnllogowidth}{\elsjnllogoheight}%
   \par\vspace*{-3pt}%   
   \rule{\textwidth}{3pt}%   
   \vspace*{18pt}%
   \endminipage%
  }%
}  

\long\def\getSpaceLeft{%\global\@twocolumnfalse%
   \global\setbox0=\vbox{\hsize=\textwidth%   
    \par\vspace*{12pt}%
    \MaketitleBox%
    \MakeabstractBox}%
   \global\setbox1=\vbox{\hsize=\textwidth
    \let\footnotetext\FNtext
    \printFirstPageNotes%
    }%
    \xdef\noteheight{\the\ht1}%
    \xdef\titleheight{\the\ht0}%
    \@tempdima=\vsize
    \advance\@tempdima-\noteheight
    \advance\@tempdima-1\baselineskip
    \xdef\savefpageheight{\the\@tempdima}%    
    \setbox2=\vbox{\titlespancalculator{\titleheight}%
                  {\savefpageheight}{\textheight}{0}}%
}

%%Maketitle for cag
  \if@twocolumn
    \def\maketitle{%
      \iflongmktitle\getSpaceLeft
         \ifdim\noteheight>0pt%
			      \advance\@tempdima-1.35\baselineskip
         \fi%
         \setcounter{cnote}{0}%         
         \setcounter{tnote}{0}%
         \setcounter{fnote}{0}%
         \global\setbox\els@boxa=\vsplit0 to \@tempdima
         \box\els@boxa%
         \printFirstPageNotes%                  
         \par\resetTitleCounters
         \thispagestyle{pprintTitle}%
         \ifnum\savetitlepagespan>1\relax%
            \myfor{2}{\savetitlepagespan}{%
            \global\setbox\els@boxb=\vsplit0 to \textheight%\@tempdima              
            \twocolumn[\unvbox\els@boxb]}
         \else%
         \fi%       
         \twocolumn[\unvbox0]%
      \else
         \twocolumn[\vspace*{10pt}\finalMaketitle]\printFirstPageNotes
      \fi
     \gdef\thefootnote{\arabic{footnote}}%
     \ifpreprint%
        \global\advance\baselineskip by 6pt%
     \fi%
     }%
  \else
     \def\maketitle{%
        \iflongmktitle\getSpaceLeft
           \ifdim\noteheight>0pt%
			        \advance\@tempdima-1.35\baselineskip
           \fi%
           \setcounter{cnote}{0}%
           \setcounter{tnote}{0}%           
           \setcounter{fnote}{0}%           
           \global\setbox\els@boxa=\vsplit0 to \@tempdima
           \printFirstPageNotes%                      
           \unvbox\els@boxa%
           \par\resetTitleCounters
           \thispagestyle{pprintTitle}%           
           \ifnum\savetitlepagespan>1\relax%
              \myfor{2}{\savetitlepagespan}{%
              \global\setbox\els@boxb=\vsplit0 to \textheight%\@tempdima              
              \unvbox\els@boxb}
           \else%
           \fi%              
           \unvbox0%
        \else
          \finalMaketitle\printFirstPageNotes
        \fi
        \gdef\thefootnote{\arabic{footnote}}%
        \ifpreprint%
           \global\advance\baselineskip by 6pt%
        \fi%
        }%
  \fi%


%% Title page header
\def\ps@REVIPTitle{%
  \def\@oddhead{%
    %\stmtitleheader
   {\titleheaderfont%
   \hfil\@journal\ (\the\year)\hfil}%    
    }%
  \let\@evenhead\@empty
  \def\@oddfoot{%
      \ifpreprint%
        \ifnopreprintline\relax\else%
             Preprint submitted to \ifx\@journal\@empty%
               Elsevier%
           \else\@journal\fi\hfill\@date%
        \fi%
      \fi%
  }
  \let\@evenfoot\@oddfoot
}

\let\ps@pprintTitle\ps@REVIPTitle

\def\ps@headings{%
   \def\@evenhead{{\titleheaderfont\rlap{\thepage}%
      \hfill\@verso\,/\,\@journal\ (\the\year)\hfill\mbox{}}}
   \def\@oddhead{{\titleheaderfont\mbox{}%
      \hfill\@verso\,/\,\@journal\ (\the\year)\hfill\llap{\thepage}}}
   \let\@oddfoot\relax
   \let\@evenfoot\@oddfoot
}

% Header for other than title page.
\pagestyle{headings}

% History info
\let\@received\@empty
\let\@finalform\@empty
\let\@accepted\@empty
\let\@availableonline\@empty
\let\@communicated\@empty
\def\received#1{\gdef\@received{#1}}
\def\finalform#1{\gdef\@finalform{#1}}
\def\accepted#1{\gdef\@accepted{#1}}
\def\availableonline#1{\gdef\@availableonline{#1}}
\def\communicated#1{\gdef\@communicated{#1}}

\def\receivedhead{Received}
\def\acceptedhead{Accepted}
\def\finalformhead{Received in final form}
\def\availableonlinehead{Available online}
\def\communicatedhead{Communicated by}

% Article info
\def\articleinfobox{%
    \parbox[t]{.25\textwidth}{%
    \vspace*{0pt}%
%    \hrule%        
%    \vspace*{6pt}%    
    \fontsize{8pt}{10pt}\selectfont%
    \textit{Article history}:\\
    \ifx\@received\@empty\relax
    \else
    \receivedhead~\@received\\
    \fi
    \ifx\@finalform\@empty\relax
    \else
    \finalformhead~\@finalform\\
    \fi
    \ifx\@accepted\@empty\relax
    \else
    \acceptedhead~\@accepted\\
    \fi
    \ifx\@availableonline\@empty\relax
    \else
    \availableonlinehead~\@availableonline
    \fi
    \ifx\@communicated\@empty\relax
    \\[-2pt]
    \else
    \par
    \vspace*{10pt}
    \communicatedhead~\@communicated
    \vspace*{12pt}
    \fi
    \hrule width 0.285\textwidth
    \vspace*{1pc}
    \unhbox\keybox}
}

% Preprint Maketitle
\long\def\pprintMaketitle{\MaketitleBox}%



% Maketitle 
\long\def\MaketitleBox{%
  \resetTitleCounters
  \stmtitleheader%
  \def\baselinestretch{1}%
  \begin{\elsarticletitlealign}%
   \def\baselinestretch{1}%
%    \vspace*{7.5pc}
    \Large\@title\par\vskip18pt
    \normalsize
  \ifdoubleblind
%    \vspace*{2pc}
  \else
    \elsauthors\par\vskip10pt
    {\footnotesize\itshape\elsaddress}\par\vskip12pt
  \fi
\vspace*{-\baselineskip}%
  \end{\elsarticletitlealign}%
%  \vspace*{2pc}
%  \printFirstPageNotes%
}

\long\def\MakeabstractBox{%
\@tempdima=.335\textwidth%
\elsptputbox(-\strip@pt\@tempdima,0)(0,0)[tl]{\MakeartinfoBox}%
{%
\leftskip=\@tempdima%
\rule{.665\textwidth}{.2pt}\\[10pt]%\vskip10pt
    \noindent\begin{tabular*}{.665\textwidth}{@{}l@{}p{.665\textwidth}}
%     \hspace*{7pt}&A~B~S~T~R~A~C~T\\[8pt]
  \multicolumn{2}{@{}l@{}}{A~B~S~T~R~A~C~T}\\[8pt]
    \hline\\[-8pt]
    \end{tabular*}
    \par\noindent%
    \unvbox\absbox%
    \mbox{}\\[\belowabstractskip]%\rule{.665\textwidth}{.2pt}%\vskip10pt%    
    \noindent\hrule%
    \if@twocolumn%
      \vspace*{24pt}%
    \fi%    
}    
}

\long\def\MakeartinfoBox{%
\vtop{\hsize=.285\textwidth%
\noindent\rule{.285\textwidth}{.2pt}\\[10pt]%\vskip10pt%
 \noindent\begin{tabular*}{.285\textwidth}{@{}l@{}p{.285\textwidth}}
%   \hspace*{7pt}&A~R~T~I~C~L~E~~I~N~F~O\\[8pt]%
   \multicolumn{2}{@{}l@{}}{A~R~T~I~C~L~E\mbox{~~~}I~N~F~O}\\[8pt]
   \hline\\[-8pt]%
 \end{tabular*}%
 \par%
\noindent\articleinfobox\\[3pt]%\hrule
}
}

\long\def\finalMaketitle{%
  \resetTitleCounters
  \def\baselinestretch{1}%
   \MaketitleBox%
   \MakeabstractBox%
   \thispagestyle{REVIPTitle}%
  \gdef\thefootnote{\arabic{footnote}}%
  }

 
\def\printFirstPageNotes{%
  \def\snm##1{##1}%
  \iflongmktitle
   \let\columnwidth=\textwidth\fi
  \ifdoubleblind
  \else
  \ifx\@tnotes\@empty\else\@tnotes\fi
  \ifx\@nonumnotes\@empty\else\@nonumnotes\fi
  \ifx\@cornotes\@empty\else\@cornotes\fi
  \ifx\@elseads\@empty\relax\else
   \let\thefootnote\relax
   \footnotetext{\ifnum\theead=1\relax
      \textit{e-mail:\space}\else
      \textit{e-mail:\space}\fi
     \@elseads}\fi
  \ifx\@elsuads\@empty\relax\else
   \let\thefootnote\relax
   \footnotetext{\textit{URL:\space}%
     \@elsuads}\fi
 \fi
  \ifx\@fnotes\@empty\else\@fnotes\fi
  \iflongmktitle\if@twocolumn
   \let\columnwidth=\Columnwidth\fi\fi
}

% Abstract
\renewenvironment{abstract}{%
  \global\setbox\absbox=\vtop\bgroup%
  \hsize=\textwidth%
  \leftskip=.335\textwidth%%
  \noindent\unskip\ignorespaces%
%  \hskip-1pt%
  }
 {\mbox{}\newline%
   \mbox{~}\hfill\copyright~\the\year\ %
   Elsevier~B.V.~All~rights~reserved.\egroup%
 }%



% Keyword
\def\keyword{%
  %\def\sep{\newline}%
  \def\sep{\unskip\ignorespaces,\space}%
  \def\MSC{\@ifnextchar[{\@MSC}{\@MSC[2000]}}%
%  \def\@MSC[##1]{\leavevmode\hbox {\it ##1~MSC:}\newline}%
  \def\@MSC[##1]{\leavevmode\hbox {\it ##1~MSC:}~}%
  \def\JEL{\newline\leavevmode\hbox {\it JEL:\space}}%
  \def\KWD{%
   \vspace*{10pt}\newline
%   \leavevmode\hbox {\it Keywords:}\newline}%
   {\it Keywords:}~}%
  \global\setbox\keybox=\hbox\bgroup\hsize=.3\textwidth%
  \fontsize{8pt}{10pt}\selectfont%
  \parskip\z@%
  \noindent%
  \ignorespaces}
\def\endkeyword{\egroup}

%% Other customization

% Enumerate
\def\labelenumii{\labelenumi.\arabic{enumii}}

% Caption
\def\figurename{Fig.}

\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip\footnotesize\bfseries
  \sbox\@tempboxa{#1.~#2}%
  \ifdim \wd\@tempboxa >\hsize
    #1.~#2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}

%\AtBeginDocument{\ifpreprint
%  \advance\baselineskip by 6pt
%\fi}

\def\TM{$^{\rm TM}$}
